#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,cnt=0,mn;
double V;
int t[100005]={0},tl=0;
long long S=0;
struct st{
    double v;
    double ad;
    int s;
}c[100005];
struct sst{
    double w;
    int l=0;
    int p[100005];
};
void solve()
{
    cnt=0;
    memset(t,0,sizeof(t));
    cin>>n>>m>>L>>V;
    sst cs[m+1];
    for(int i=1;i<=n;i++)
    {
        cin>>c[i].s>>c[i].v>>c[i].ad;
    }
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>cs[i].w;
    }
    for(int i=1;i<=n;i++)
    {
        int w=c[i].ad==0?c[i].s:c[i].s+(V*V-c[i].v*c[i].v)/(double)2*c[i].ad;
        for(int o=1;o<=m;o++)
        {
            if((c[i].ad>0&&cs[o].w>=w&&w<=L)||(c[i].ad<0&&cs[o].w>=c[i].s&&cs[o].w<=w)||(c[i].ad==0&&c[i].v>3&&cs[o].w>=c[i].s))
            {
                cs[o].p[++cs[o].l]=i;
                if(t[i]==0)cnt++;
                t[i]=1;
            }
        }
    }
    cout<<cnt<<" ";
    mn=9999999;
    S=0;
    for(;S<=(1<<m)-1;S++)
    {
        int tt[100005],pp=0,cn=0;
        for(int i=1;i<=100004;i++)
        {
            tt[i]=t[i];
        }
        int ss=S;
        while(ss)
        {
            cn+=ss%2;
            ss/=2;
        }
        ss=S;
        for(int i=1;i<=m;i++)
        {
            if(ss%2==1)
            {
                for(int o=1;o<=cs[i].l;o++)
                {
                    if(tt[cs[i].p[o]]==1)
                    {
                        tt[cs[i].p[o]]=0;
                        pp++;
                    }
                }
            }
            ss/=2;
        }
        if(pp==cnt)mn=min(mn,cn);
    }
    cout<<m-mn;
}
int main()
{

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int i=0;i<T;i++)
    {
        solve();
        if(i!=T-1)cout<<endl;
    }

    return 0;
}
